package com.huike.service;

import com.huike.mapper.DrugMapper;
import com.huike.pojo.Drug;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrugService {

    @Autowired
    DrugMapper drugMapper;

    public List<Drug> getDrugs(String drugName, String drugType){
        return drugMapper.getDrugs(drugName,drugType);
    }

    public Integer addDrug(Drug drug){
        return drugMapper.addDrug(drug);
    }

    public Drug getDrugsById(Integer id){
        return drugMapper.getDrugsById(id);
    }

    public Integer addResetNumber(Integer id,Integer increase){
       updateInTheSale(id);
       return drugMapper.addResetNumber(id,increase);
    }

    public  List<Drug> getDrugsByHospitalId(Integer id){
        return drugMapper.getDrugsByHospitalId(id);
    }
    public Integer updateLogo(Integer id,String img){
        return drugMapper.updateLogo(id,img);
    }

    public Integer updateInTheSale(Integer id){
       return drugMapper.updateInTheSale(id);
    }

    public Integer updateDrug(Drug drug){
        return drugMapper.updateDrug(drug);
    }

    public Integer addDrugHospital(Integer drugId,Integer hospitalId){
        return drugMapper.addDrugHospital(drugId,hospitalId);
    }

    public Integer subtractResetNumber(Integer id,Integer increase){
        return drugMapper.subtractResetNumber(id,increase);
    }

    public List<Drug> getRegisterDrug(Integer id){
        return drugMapper.getRegisterDrug(id);
    }

    public Integer getDrugNumbe(Integer id,Integer drugId){
        return drugMapper.getDrugNumbe(id,drugId);
    }

    public Integer grantDrug(Integer id,Integer drugId,Integer number){
        return drugMapper.grantDrug(id,drugId,number);
    }

}
